﻿<%@ Page Title="" Language="C#" MasterPageFile="~/PageTemplate.Master" AutoEventWireup="true" CodeBehind="Checkout.aspx.cs" Inherits="RMS.Pages.Checkout" %>

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContent" runat="server">
    <!-- Checkout Web Form handles Retreat registration. -->
    <div id="content" runat="server">
        <div id="checkoutForm" class="checkout" runat="server">
            <h1>Retreat Registration</h1>    
            <hr />
            <h3> Retreat Selection:</h3>
            <br />
            <!-- Display Retreat Selection -->
            <table id="cartTable">
                <thead><tr>
                    <th>Retreat Title</th>
                    <th>Cost</th>
                    <th>Qty</th>
                </tr></thead>

                <tbody>
                    <asp:Repeater ID="Repeater1" ItemType="RMS.Models.CartLine" SelectMethod="GetCartLines" runat="server" EnableViewState="false">
                        <ItemTemplate>
                            <tr>
                                <td><%# Item.Retreat.Ret_Title %></td>
                                <td><%# Item.Retreat.Ret_Cost.ToString("c")%></td>
                                <td><%# Item.Quantity%></td>
                            </tr>
                            <input type="hidden" <%# currentRetreatDate = Item.Retreat.Ret_Dates.ToString() %>/>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
                <tfoot>
                    <tr>
                        <td class="greentext">
                            Reservation Total:
                        </td>
                        <td>
                            <%= CartTotal.ToString("c") %>
                        </td>
                    </tr>
                </tfoot>
               
            </table>
            

            <!-- Validation Summary -->                
            <div id="errors"  data-valmsg-summary="true">
                <ul><li style="display:none"></li></ul>
                <asp:ValidationSummary ID="ValidationSummary1" runat="server"/>
            </div>
        
            <h2>Retreatant Information:</h2>
            <hr />
        
            <%if (Session["ID"] == null)
              {
                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_Fname\">First Name:</label>");
                  Response.Write("<input id=\"Res_Fname\" class=\"lettersOnly\" name=\"Res_Fname\" data-val=\"true\" data-val-required= \"Please enter your first name.\" />");
                  Response.Write("</div>");
                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_Lname\">Last Name:</label> ");
                  Response.Write("<input id=\"Res_Lname\" class=\"lettersOnly\" name=\"Res_Lname\" data-val=\"true\" data-val-required= \"Please enter your last name.\" />");
                  Response.Write("</div>");
                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_Address\">Address:</label>");
                  Response.Write("<input id=\"Res_Address\" name=\"Res_Address\" data-val=\"true\" data-val-required= \"Please enter your address.\" />");
                  Response.Write("</div>");
                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_City\">City:</label> ");
                  Response.Write("<input id=\"Res_City\" class=\"lettersOnly\" name=\"Res_City\" data-val=\"true\" data-val-required= \"Please enter your city.\" />");
                  Response.Write("</div> ");
                  Response.Write("<div>");
                  Response.Write(" <label for=\"Res_State\">State:</label> ");

                  Response.Write("<select id=\"states\" name=\"Res_State\" class=\"statesOption\">");
                     Response.Write("<option value=\"WI\">WI</option>");
                     Response.Write("<option value=\"AL\">AL</option>");
                     Response.Write("<option value=\"AK\">AK</option>");
                     Response.Write("<option value=\"AZ\">AZ</option>");
                     Response.Write("<option value=\"AR\">AR</option>");    
                     Response.Write("<option value=\"CA\">CA</option>");    
                     Response.Write("<option value=\"CO\">CO</option>");    
                     Response.Write("<option value=\"CT\">CT</option>");    
                     Response.Write("<option value=\"DE\">DE</option>");    
                     Response.Write("<option value=\"DC\">DC</option>");    
                     Response.Write("<option value=\"FL\">FL</option>");    
                     Response.Write("<option value=\"GA\">GE</option>");    
                     Response.Write("<option value=\"HI\">HI</option>");    
                     Response.Write("<option value=\"ID\">ID</option>");    
                     Response.Write("<option value=\"IL\">IL</option>");    
                     Response.Write("<option value=\"IN\">IN</option>");    
                     Response.Write("<option value=\"IA\">IA</option>");    
                     Response.Write("<option value=\"KS\">KS</option>");   
                     Response.Write("option value=\"KY\">KY</option>");    
                     Response.Write("<option value=\"LA\">LA</option>");   
                     Response.Write("option value=\"ME\">ME</option>");
                     Response.Write("<option value=\"MD\">MD</option>");
                     Response.Write("option value=\"MA\">MA</option>");
                     Response.Write("<option value=\"MI\">MI</option>");
                     Response.Write("<option value=\"MN\">MN</option>");
                     Response.Write("<option value=\"MS\">MS</option>");
                     Response.Write("<option value=\"MO\">MO</option>");
                     Response.Write("<option value=\"MT\">MT</option>");
                     Response.Write("<option value=\"NE\">NE</option>");    
                     Response.Write("<option value=\"NV\">NV</option>");    
                     Response.Write("<option value=\"NH\">NH</option>");    
                     Response.Write("<option value=\"NJ\">NJ</option>");    
                     Response.Write("<option value=\"NM\">NM</option>");
                     Response.Write("<option value=\"NY\">NY</option>");    
                     Response.Write("<option value=\"NC\">NC</option>");
                     Response.Write("<option value=\"ND\">ND</option>");
                     Response.Write("option value=\"OH\">OH</option>");    
                     Response.Write("<option value=\"OK\">OK</option>");
                     Response.Write("<option value=\"OR\">OR</option>");
                     Response.Write("<option value=\"PA\">PA</option>");
                     Response.Write("<option value=\"RI\">RI</option>");
                     Response.Write("<option value=\"SC\">SC</option>");
                     Response.Write("<option value=\"SD\">SD</option>");
                     Response.Write("<option value=\"TN\">TN</option>");
                     Response.Write("<option value=\"TX\">TX</option>");
                     Response.Write("<option value=\"UT\">UT</option>");
                     Response.Write("<option value=\"VT\">VT</option>");    
                     Response.Write("<option value=\"VA\">VA</option>");
                     Response.Write("<option value=\"WA\">WA</option>");    
                     Response.Write("<option value=\"WV\">WV</option>");    
                     Response.Write("<option value=\"WI\">WI</option>");
                     Response.Write("<option value=\"WY\">WY</option></select>");
                           
                  
                  Response.Write("</div>  ");
                  Response.Write("<div>");
                  Response.Write(" <label for=\"Res_Zipcode\">Zipcode:</label> ");
                  Response.Write("<input id=\"Res_Zipcode\" class=\"numbersOnly\" name=\"Res_Zipcode\" data-val=\"true\" data-val-required= \"Please enter your zipcode.\"/>");
                  Response.Write("</div>  ");
                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_Phone\">Phone:</label> ");
                  Response.Write("<input id=\"Res_Phone\" class=\"numbersOnly\" name=\"Res_Phone\" data-val=\"true\" data-val-required= \"Please enter your phone number.\" class=\"test\"/>");
                  Response.Write("</div>  ");
                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_Email\">E-mail:</label> ");
                  Response.Write("<input id=\"Res_Email\" name=\"Res_Email\" data-val=\"true\" data-val-required= \"Please enter your E-Mail address.\"/>");
                  Response.Write("</div> ");
              }
              else
              {
                  RMS.Models.DatabaseManager.UserManager manager = new RMS.Models.DatabaseManager.UserManager();
                  RMS.Models.User user = manager.GetUser((int)Session["ID"]);

                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_Fname\">First Name:</label>");
                  Response.Write("<input id=\"Res_Fname\" name=\"Res_Fname\" data-val=\"true\" value=\""+user.Us_FName+"\" readonly/>");
                  Response.Write("</div>");
                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_Lname\">Last Name:</label> ");
                  Response.Write("<input id=\"Res_Lname\" name=\"Res_Lname\" data-val=\"true\" value=\"" + user.Us_LName + "\" readonly/>");
                  Response.Write("</div>");
                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_Address\">Address:</label>");
                  Response.Write("<input id=\"Res_Address\" name=\"Res_Address\" data-val=\"true\" value=\"" + user.Us_Address + "\" readonly/>");
                  Response.Write("</div>");
                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_City\">City:</label> ");
                  Response.Write("<input id=\"Res_City\" name=\"Res_City\" data-val=\"true\" value=\"" + user.Us_City + "\" readonly/>");
                  Response.Write("</div> ");
                  Response.Write("<div>");
                  Response.Write(" <label for=\"Res_State\">State:</label> ");
                  Response.Write("<input id=\"Res_State\" name=\"Res_State\" data-val=\"true\" value=\"" + user.Us_State + "\" readonly/>");
                  Response.Write("</div>  ");
                  Response.Write("<div>");
                  Response.Write(" <label for=\"Res_Zipcode\">Zipcode:</label> ");
                  Response.Write("<input id=\"Res_Zipcode\" name=\"Res_Zipcode\" data-val=\"true\" value=\"" + user.Us_Zip + "\" readonly/>");
                  Response.Write("</div>  ");
                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_Phone\">Phone:</label> ");
                  Response.Write("<input id=\"Res_Phone\" name=\"Res_Phone\" data-val=\"true\" value=\"" + user.Us_Phone + "\" readonly/>");
                  Response.Write("</div>  ");
                  Response.Write("<div>");
                  Response.Write("<label for=\"Res_Email\">E-mail:</label> ");
                  Response.Write("<input id=\"Res_Email\" name=\"Res_Email\" data-val=\"true\" value=\"" + user.Us_Email + "\" readonly/>");
                  Response.Write("</div> ");
             }
            %>
             
            <h2>Retreat Accommodations</h2>
            <hr />
            <!-- Chosen Retreat Date Field -->
            <div>
                <label for="Res_Chosen_Date">Retreat Date:</label> 
                <!--<input id="Res_Chosen_Date" name="Res_Chosen_Date" data-val="true" data-val-required= "Please choose a retreat date." />-->
                <select name="Res_Chosen_Date">
                    <%= dateFormat(currentRetreatDate)%>
                </select>
                
            </div> 
            <!-- Reservation Issue Date Field -->
            <div>
                <label for="Res_Issue_Date"> Today's Date:</label> 
                <input id="Res_Issue_Date" name="Res_Issue_Date" value="<%: DateTime.Now.Month %>-<%: DateTime.Now.Day %>-<%: DateTime.Now.Year %>" readonly="true" />
            </div>
       
            <p> </p>
              
            <!-- Require First Floor Checkbox -->
           <input type="checkbox" id="Res_First_Floor" name="Res_First_Floor" value="true"  />
            I require a first floor room.<br />
            <!-- Dietary Needs Checkbox -->
           <input type="checkbox" id="Res_Diet_Needs" name="Res_Diet_Needs" value="true" />
            I have special dietary needs.<br />
            <!-- Require First Floor Checkbox -->
            <input type="checkbox" id="Res_Multiple_Guests" name="Res_Multiple_Guests" value="true" />
            I have multiple guests.<br />
            <p> </p>
             <!-- Guest Info Field -->
            <div>
                <label for="Res_Guest_Info">Guest Info:</label> 
                <!--<input id="Res_Guest_Info" name="Res_Guest_Info" />-->
                <textarea rows="4" cols="64" name="Res_Guest_Info"></textarea>

            </div> 

            <h2>Payment Information</h2>
            <hr />
        
            <ul>
                    <li>
                        <b>A non-refundable deposit of $50.00 is required with registration.</b>
                    </li>
            </ul>
        
             <!-- Pay by Check Checkbox -->
           <input type="checkbox" id="Res_Pay_Check" name="Res_Pay_Check" value="true"  />
            Pay by Check: Redemptorist Retreat Center <br />
            <!-- Pay by Credit Checkbox -->
           <input type="checkbox" id="Res_Pay_Credit" name="Res_Pay_Credit" value="true" />
            Pay by Credit: <i>Please call to pay by credit card.</i><br />
            <br />
            <p>
                <button class="myButton" type="submit">Submit Retreat Reservation</button>
            </p>
        </div>
        <div id="checkoutMessage" runat="server">
            <h1>Retreat Registration Successful!</h1>
            <hr />
            <h3> You are currently registered for:</h3>
            <br />
            <%=GetResultString %>
            <br />
            <br />
            
            <table>
                <tr>
                    <td class="greentext">
                        <span>ReservatationTotal: </span>
                    </td>
                    <td>
                        <%=GetResultTotal.ToString("c") %>
                    </td>
                </tr>
            </table>
            
            <p><br /></p>
            <i><span style="color:rgb(0, 100, 0);"><% GenerateEmail(); %></span></i>
            <p><br /></p>            
       </div>
    </div>
</asp:Content>
